Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(jest-transform): improve runtime errors and warnings #11998

Merged
merged 5 commits into from
Nov 1, 2021
Merged

fix(jest-transform): improve runtime errors and warnings #11998

merged 5 commits into from
Nov 1, 2021

Conversation

mrazauskas
Copy link
Contributor

Summary

Resolves #11955

It would be useful to provide more information if a user is attempting to import an invalid transformer module. Current message does not specify modules name. Hence, it may be hard to identify the problem.

This PR is an attempt to improve the error message.

Test plan

Updated the existing tests.

@@ -250,6 +251,21 @@ class ScriptTransformer {
}

async loadTransformers(): Promise<void> {
const makeInvalidTransformerError = (transformPath: string) =>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could also live outside the class, of course. The class is huge, not so easy to decide.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense to move it outside rather than defining it inline 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or even better to move it to separate file together with other runtime errors for this module. Had to think a bit, will do it later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that also works - as you say the class is huge and somewhat hard to grok/navigate

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@mrazauskas mrazauskas changed the title fix(jest-transform): throw better errors if a transformer module is not valid fix(jest-transform): improve runtime errors and warnings Oct 29, 2021
@SimenB SimenB merged commit 10d9580 into jestjs:main Nov 1, 2021
@mrazauskas mrazauskas deleted the fix-transformer-errors branch November 1, 2021 14:23
@github-actions
Copy link

github-actions bot commented Dec 2, 2021

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Jest and babel-jest 27.3.0v update gives error on running tests
3 participants